<?php

namespace App\Kuafu\Shop\Listeners;

use App\Kuafu\Mqtt\Service\MqttService;
use App\Kuafu\Shop\Enum\ShopCacheEnum;
use App\Kuafu\Shop\Events\PaymentShopUpdateEvent;
use App\Library\Redis\RedisHelp;
use Illuminate\Support\Facades\Cache;

class PaymentShopUpdateNotify
{
    /**
     * Create the event listener.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Handle the event.
     *
     * @param PaymentShopUpdateEvent $event
     * @return void
     */
    public function handle(PaymentShopUpdateEvent $event)
    {
        if (!empty($event->shopIds)) {
            RedisHelp::getInstance()->remove(array_map(function ($v) {
                return ShopCacheEnum::getShopCustomPayment($v);
            }, $event->shopIds));
            foreach ($event->shopIds as $shopId) {
//                (new MqttService(0, $shopId))->updateCustomPayment();
            }
        }
    }
}
